<?php
 
class Graficas_model extends CI_Model {
      function __construct(){
        parent::__construct();
    }
 
    public function UltimasCincoHumedades() {
        
  
  	$query = $this->couchdb->limit(5)->descending(TRUE)->getView('arduino','datoshum');
  	
	//$fecha = date("d-m-Y H:i:s",($query->rows[0]->key));
 
 	$datos['valor1'] = $query->rows[0]->value[1];
	$datos['fecha1'] = date("d-m-Y H:i:s",($query->rows[0]->key));
        $datos['valor2'] = $query->rows[1]->value[1];
	$datos['fecha2'] = date("d-m-Y H:i:s",($query->rows[1]->key));
        $datos['valor3'] = $query->rows[2]->value[1];
	$datos['fecha3'] = date("d-m-Y H:i:s",($query->rows[2]->key));
        $datos['valor4'] = $query->rows[3]->value[1];
	$datos['fecha4'] = date("d-m-Y H:i:s",($query->rows[3]->key));
        $datos['valor5'] = $query->rows[4]->value[1];
	$datos['fecha5'] = date("d-m-Y H:i:s",($query->rows[4]->key));
	
	
        return $datos;
    }
    public function UltimasCincoTemperaturas() {
        
  
  	$query = $this->couchdb->limit(5)->descending(TRUE)->getView('arduino','datostemp');
  	
	//$fecha = date("d-m-Y H:i:s",($query->rows[0]->key));
 
 	$datos['valor1'] = $query->rows[0]->value[1];
	$datos['fecha1'] = date("d-m-Y H:i:s",($query->rows[0]->key));
        $datos['valor2'] = $query->rows[1]->value[1];
	$datos['fecha2'] = date("d-m-Y H:i:s",($query->rows[1]->key));
        $datos['valor3'] = $query->rows[2]->value[1];
	$datos['fecha3'] = date("d-m-Y H:i:s",($query->rows[2]->key));
        $datos['valor4'] = $query->rows[3]->value[1];
	$datos['fecha4'] = date("d-m-Y H:i:s",($query->rows[3]->key));
        $datos['valor5'] = $query->rows[4]->value[1];
	$datos['fecha5'] = date("d-m-Y H:i:s",($query->rows[4]->key));
	
	
        return $datos;
    }
    
   
    
}
 
?>